package com.woniuxy.service.fix;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.Fix;
import com.woniuxy.mapper.FixMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class FixServiceImpl implements FixService{
    @Autowired
    private FixMapper fixMapper;

    @Override
    public PageInfo<Fix> findAll(Integer page, Integer size) {
        PageHelper.startPage(page,size);
        List<Fix> fixes = fixMapper.selectByExample(null);
        PageInfo info = new PageInfo(fixes);
        return info;
    }

    @Override
    public int update(Fix fix) {
        return fixMapper.updateByPrimaryKeySelective(fix);
    }

    @Override
    public int delete(Integer fId) {
        return fixMapper.deleteByPrimaryKey(fId);
    }

    @Override
    public void fixAfterSave(Fix fix) {
        fixMapper.save(fix);
    }
}
